// react
import React from 'react'

// 导入组件
import Layout from '../components/layout'

// 导入路由懒加载
import withLoadable from '../utils/with-loadable'

// 登陆
const Login = withLoadable(() => import('../views/login/login'))

// 首页
const Home = withLoadable(() => import('../views/home/home'))

// 仓库管理
const Inventory = withLoadable(() =>  import('../views/inventory/inventory'))
const InventoryList = withLoadable(() =>  import('../views/inventory/inventoryList'))
const InventoryPost = withLoadable(() =>  import('../views/inventory/inventoryPost'))
const InventoryNews = withLoadable(() =>  import('../views/inventory/inventoryNews'))

// 销售管理
const Sales = withLoadable(() => import('../views/sales/sales'))
const OnSales = withLoadable(() => import('../views/sales/onSales'))
const HasSales = withLoadable(() => import('../views/sales/hasSales'))
const OnSalesNews = withLoadable(() => import('../views/sales/onSalesNews'))

// 员工管理
const Staffs =  withLoadable(() => import('../views/staffs/staffs'))
const StaffsList =  withLoadable(() => import('../views/staffs/staffsList'))
const AddStaff =  withLoadable(() => import('../views/staffs/addStaff'))
const StaffInfo =  withLoadable(() => import('../views/staffs/staffInfo'))

// 消息记录
const Record = withLoadable(() => import('../views/record/record'))

// 导入图标
import { UserOutlined, HomeFilled, HddFilled, ShopFilled, SettingFilled } from '@ant-design/icons';

const routes = [
  {
    path: '/login',
    to: 'to',
    component: Login,
    exact: true,
  },
  {
    path: '/*',
    to: '/',
    component: Layout,
    children: [
      {
        to: 'home',
        path: 'home',
        component: Home,
        exact: true,
        meta: {
          title: '首页',
          icon: HomeFilled,
        },
      },
      {
        path: 'inventory/*',
        to: 'inventory',
        component: Inventory,
        exact: true,
        meta: {
          title: '货存管理',
          icon: HddFilled,
        },
        children: [
          {
            path: 'inventoryList',
            to: 'inventory/inventoryList',
            component: InventoryList,
            exact: true,
            meta: {
              title: '货存列表',
            },
          },
          {
            path: 'inventoryPost',
            to: 'inventory/inventoryPost',
            component: InventoryPost,
            exact: true,
            meta: {
              title: '新品进库',
              noRender: true,
            },
          },
          {
            path: 'inventoryNews',
            to: 'inventory/inventoryNews',
            component: InventoryNews,
            exact: true,
            meta: {
              title: '货存通知',
            },
          },
        ],
      },
      {
        path: 'sales/*',
        to: 'sales',
        component: Sales,
        exact: true,
        meta: {
          title: '销售管理',
          icon: ShopFilled,
        },
        children: [
          {
            path: 'onSales',
            to: 'sales/onSales',
            component: OnSales,
            exact: true,
            meta: {
              title: '正在销售',
            },
          },
          {
            path: 'hasSales',
            to: 'sales/hasSales',
            component: HasSales,
            exact: true,
            meta: {
              title: '销售账单',
            },
          },
          {
            path: 'onSalesNews',
            to: 'sales/onSalesNews',
            component: OnSalesNews,
            exact: true,
            meta: {
              title: '销售通知',
            },
          },
        ],
      },
      {
        path: 'staffs/*',
        to: 'staffs',
        component: Staffs,
        exact: true,
        meta: {
          title: '员工管理',
          icon: UserOutlined,
        },
        children: [
          {
            path: 'staffsList',
            to: 'staffs/staffsList',
            component: StaffsList,
            exact: true,
            meta: {
              title: '员工列表',
            },
          },
          {
            path: 'addStaff',
            to: 'staffs/addStaff',
            component: AddStaff,
            exact: true,
            meta: {
              title: '新增员工',
            },
          },
          {
            path: 'staffInfo',
            to: 'staffs/staffInfo',
            component: StaffInfo,
            exact: true,
            meta: {
              title: '员工信息',
              noRender: true,
            },
          },
        ],
      },
      {
        path: 'record/*',
        to: 'record',
        component: Record,
        exact: true,
        meta: {
          title: '消息记录',
          icon: ShopFilled,
        },
      },
    ],
  },
]

export default routes
